<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<div class="button_area">
	<a href="role/role.detail.action" class="button">添加</a>
</div>

<script type="text/javascript">
var GridOption={        
			url:'role/role.list.action?'+$('form').serialize(),
     		datatype: 'json',  
     		jsonReader:{ root: "dataRows"},   
    		colModel:[       
       			{label:'序号',name:'roleId',index:'roleId',key:true},     
       			{label:'角色名称',name:'roleName',index:'roleName',required:true, width:100,editable:false,formatter:'showlink', formatoptions:{baseLinkUrl:'role/role.detail.action'}},     
        		{label:'是否为管理员',name:'admin',index:'admin', width:100,editable:false},       
        		{label:'可使用的功能',name:'functions',index:'functions', width:100,editable:false},       
        		{label:' ',name:'del', width:100,align:'center',sortable:false}
     		],     
     		imgpath: '../theme/images/jqgrid/',      
    		pager: "#pjmap",   
      		multiselect: false,     
     		sortname: 'roleId',     
      		viewrecords: true,     
      		sortorder: "ASC",     
      		jsonReader: {     
	      		root: "dataRows",
	      		repeatitems : false
     		},
     		gridComplete: function(){
				var ids = jQuery("#list").jqGrid('getDataIDs');
				for(var i=0;i < ids.length;i++){
					var cl = ids[i];
					var data=jQuery("#list").jqGrid('getRowData',cl);
					sc= "<a href='javascript:void(0)' onclick=\"GridOption.doDelete("+cl+");\">删除</a>";
					jQuery("#list").jqGrid('setRowData',ids[i],{del:sc});
					if(data.admin=="true"){
						$(this).jqGrid('setRowData',ids[i],{admin:"是"});
						//$(this).jqGrid('setRowData',ids[i],{functions:"全部功能"});
					}else{
						$(this).jqGrid('setRowData',ids[i],{admin:"否"});
					}
				}
			},
    		width:$(document).width()-80,
    		height: $(document).height()-160,
    		doDelete:function(id){
    			var data=jQuery("#list").jqGrid('getRowData',id);
    			$("#list").delGridRow(id,{url:'role/role.delete.action',caption:'请确认',msg:'确认删除 "'+data.roleName+'" 吗?',bSubmit:'确认',bCancel:'取消',reloadAfterSubmit:true});
    			
    		},
    		doSearch:function(){
    			$("#list").setGridParam({url:"role/roleList.action?"+$('form').serialize()});
      			$("#list").trigger("reloadGrid");
    		}
    };
</script>
